﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.TeamFoundation.WorkItemTracking.Controls;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace TFSWorkflowControl.TeamExplorer
{
    public partial class WorkflowControl : UserControl, IWorkItemControl
    {
        private object _workItemDataSource;

        public WorkflowControl()
        {
            InitializeComponent();
        }

        private WorkItem CurrentWorkItem
        {
            get
            {
                return WorkItemDatasource as WorkItem;
            }
        }


        private void RefreshWI()
        {
            wiStateControl2.WorkItem = CurrentWorkItem;

        }

        #region IWorkItemControl Members

        public event EventHandler AfterUpdateDatasource;

        public event EventHandler BeforeUpdateDatasource;

        public void Clear()
        {
            
        }

        public void FlushToDatasource()
        {
            
        }

        public void InvalidateDatasource()
        {
            wiStateControl2.WorkItem = CurrentWorkItem;
            wiStateControl2.Refresh();
        }

        public System.Collections.Specialized.StringDictionary Properties
        {
            get;
            set;
        }

        public bool ReadOnly
        {
            get;
            set;
        }

        public void SetSite(IServiceProvider serviceProvider)
        {
           
        }

        public object WorkItemDatasource
        {
            get
            {
                return _workItemDataSource;
            }
            set
            {
                _workItemDataSource = value;
                RefreshWI();
            }
        }

        public string WorkItemFieldName
        {
            get;
            set;
        }

        #endregion
    }
}
